'\"macro stdmacro
.\"
.\" Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
.\"
.\" This program is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License as published by the
.\" Free Software Foundation; either version 2 of the License, or (at your
.\" option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful, but
.\" WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
.\" or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
.\" for more details.
.\"
.\"
.TH PMDADAEMON 3 "PCP" "Performance Co-Pilot"
.SH NAME
\f3pmdaDaemon\f1 \- initialize the PMDA to run as a daemon
.SH "C SYNOPSIS"
.ft 3
.ad l
.hy 0
#include <pcp/pmapi.h>
.br
#include <pcp/pmda.h>
.sp
void pmdaDaemon(pmdaInterface *\fIdispatch\fP,
'in +\w'void pmdaDaemon('u
int\ \fIinterface\fP,
const\ char\ *\fIname\fP,
int\ \fIdomain\fP,
const\ char\ *\fIlogfile\fP,
const\ char\ *\fIhelptext\fP);
.in
.sp
cc ... \-lpcp_pmda \-lpcp
.hy
.ad
.ft 1
.SH DESCRIPTION
.B pmdaDaemon
initializes the
.B pmdaInterface
structure to use the
.I interface
extensions assuming the
.BR PMDA (3)
is to be run as a daemon.  The
.B pmdaInterface
structure is initialized with:
.TP 15
.I name
The name of the agent.
.TP
.I domain
The default domain number of the agent which uniquely identifies this PMDA
from other running PMDAs.  This may be subsequently changed by a command line
option
.B \-d
(see
.BR pmdaGetOpt (3)).
.TP
.I logfile
The default path to the log file.  This may be replaced by the
.B \-l
command line option if using
.BR pmdaGetOpt .
.I logfile
will be copied with
.BR strdup (3),
so the storage associated with
.I logfile
may be released after the call to
.BR pmdaDaemon .
.TP
.I helptext
The default path to the help text (see
.BR pmdaText (3).
This may be replaced by the
.B \-h
command line option if using
.BR pmdaGetOpt (3).
If no help text is installed, or you are not using
.BR pmdaText (3),
then this should be set to NULL, otherwise
.I helptext
will be copied with
.BR strdup (3),
so the storage associated with
.I helptext
may be released after the call to
.BR pmdaDaemon .
.PP
The callbacks are initialized to
.BR pmdaProfile (3),
.BR pmdaFetch (3),
.BR pmdaDesc (3),
.BR pmdaText (3),
.BR pmdaInstance (3)
and
.BR pmdaStore (3).
.SH CAVEAT
The PMDA must be using
.B PMDA_INTERFACE_2
or later.
.PP
Once
.B pmdaDaemon
has been called, it is expected that the
.B pmdaInterface
structure pointed to by
.I dispatch
will remain accessible to the
routines in
.I libpcp_pmda
(not reclaimed off the stack,
not freed or otherwise released, etc.).
If the caller needs to move or relocate the
.B pmdaInterface
structure for any reason, then after the move
.BR pmdaInterfaceMoved (3)
must be called to re-establish the internal integrity of the
.I pmdaInterface
structure at the new location before any other routine in
.I libpcp_pmda
is called.
.SH DIAGNOSTICS
.TP 15
.B Unable to allocate memory for pmdaExt structure
In addition, the
.I dispatch->status
field is set to a value less than zero.
.TP
.BI "PMDA interface version " interface " not supported"
The
.I interface
version is not supported by
.BR pmdaDaemon .
.SH SEE ALSO
.BR PMAPI (3),
.BR PMDA (3),
.BR pmdaDSO (3),
.BR pmdaGetOpt (3),
.BR pmdaInterfaceMoved (3)
and
.BR pmdaText (3).
